package org.subside.thread;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.crypto.spec.SecretKeySpec;
import java.security.SecureRandom;
import java.util.Date;

/**
 * @Author : zhangbo
 * @data : 2024/5/8
 * @description :
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class EmpDto {
//    private Integer id;
    private String  name;
    private Integer  salary;
    private Integer  bonus;
    private String time;
    private String  department;

    public static void main(String[] args) {
        // 生成128位的随机密钥
        byte[] keyBytes = new byte[8]; // AES-128位密钥长度为16字节
        SecureRandom random = new SecureRandom();
        random.nextBytes(keyBytes);

        // 将字节数组转换为十六进制字符串，用于显示
        String keyString = bytesToHex(keyBytes);

        // 创建一个AES密钥
        SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES");
        System.out.println(keyString.length());
        // 打印生成的密钥
        System.out.println("Generated AES-128 bit key: " + keyString);
    }
    private static String bytesToHex(byte[] bytes) {
        StringBuilder hexString = new StringBuilder(2 * bytes.length);
        for (int i = 0; i < bytes.length; i++) {
            String hex = Integer.toHexString(0xff & bytes[i]);
            if (hex.length() == 1) {
                hexString.append('0');
            }
            hexString.append(hex);
        }
        return hexString.toString();
    }
}

